/*!
 * File:
 *  si446x_api_lib.h
 *
 * Description:
 *  This file contains the Si446x API library.
 *
 * Silicon Laboratories Confidential
 * Copyright 2011 Silicon Laboratories, Inc.
 */

#ifndef _SI446X_API_LIB_H_
#define _SI446X_API_LIB_H_

extern union si446x_cmd_reply_union  Si446xCmd;
extern unsigned char Pro2Cmd[16];


#define SI466X_FIFO_SIZE 64

enum
{
    SI446X_SUCCESS,
    SI446X_NO_PATCH,
    SI446X_CTS_TIMEOUT,
    SI446X_PATCH_FAIL,
    SI446X_COMMAND_ERROR
};

/* Minimal driver support functions */
void si446x_reset(void);
void si446x_power_up(unsigned char BOOT_OPTIONS, unsigned char XTAL_OPTIONS, unsigned  int XO_FREQ);

unsigned char si446x_configuration_init(const unsigned char* pSetPropCmd);
unsigned char si446x_apply_patch(void);
void si446x_part_info(void);

void si446x_start_tx(unsigned char CHANNEL, unsigned char CONDITION, unsigned short TX_LEN);
void si446x_start_rx(unsigned char CHANNEL, unsigned char CONDITION, unsigned short RX_LEN, unsigned char NEXT_STATE1, unsigned char NEXT_STATE2, unsigned char NEXT_STATE3);

void si446x_get_int_status(unsigned char PH_CLR_PEND, unsigned char MODEM_CLR_PEND, unsigned char CHIP_CLR_PEND);
void si446x_gpio_pin_cfg(unsigned char GPIO0, unsigned char GPIO1, unsigned char GPIO2, unsigned char GPIO3, unsigned char NIRQ, unsigned char SDO, unsigned char GEN_CONFIG);

void si446x_set_property( unsigned char GROUP, unsigned char NUM_PROPS, unsigned char START_PROP, ... );
void si446x_change_state(unsigned char NEXT_STATE1);
#define RADIO_DRIVER_EXTENDED_SUPPORT
#define RADIO_DRIVER_FULL_SUPPORT
#ifdef RADIO_DRIVER_EXTENDED_SUPPORT
  /* Extended driver support functions */
  void si446x_nop(void);

  void si446x_fifo_info(unsigned char FIFO);
  void si446x_write_tx_fifo( unsigned char numBytes, unsigned char* pData );
  void si446x_read_rx_fifo( unsigned char numBytes, unsigned char* pRxData );

  void si446x_get_property(unsigned char GROUP, unsigned char NUM_PROPS, unsigned char START_PROP);

  #ifdef RADIO_DRIVER_FULL_SUPPORT
    /* Full driver support functions */
    void si446x_func_info(void);

    void si446x_frr_a_read(unsigned char respByteCount);
    void si446x_frr_b_read(unsigned char respByteCount);
    void si446x_frr_c_read(unsigned char respByteCount);
    void si446x_frr_d_read(unsigned char respByteCount);

    void si446x_get_adc_reading(unsigned char ADC_EN);
    void si446x_get_packet_info(unsigned char FIELD_NUMBER_MASK, unsigned short LEN, signed short DIFF_LEN );
    void si446x_get_ph_status(unsigned char PH_CLR_PEND);
    void si446x_get_modem_status( unsigned char MODEM_CLR_PEND );
    void si446x_get_chip_status( unsigned char CHIP_CLR_PEND );

    void si446x_ircal(unsigned char SEARCHING_STEP_SIZE, unsigned char SEARCHING_RSSI_AVG, unsigned char RX_CHAIN_SETTING1, unsigned char RX_CHAIN_SETTING2);
    void si446x_protocol_cfg(unsigned char PROTOCOL);

    void si446x_request_device_state(void);

    void si446x_rx_hop(unsigned char INTE, unsigned char FRAC2, unsigned char FRAC1, unsigned char FRAC0, unsigned char VCO_CNT1, unsigned char VCO_CNT0);
    void si446x_agc_override(unsigned char AGC_OVERRIDE);
  #endif
#endif


#endif //_SI446X_API_LIB_H_
